﻿package com.boyaa.shells.tool 
{
	import flash.display.Shape;
	
	/**
	 * ...
	 * @author fly
	 */
	public class Draw 
	{
		
		/**
		 *  圓
		 * @param	halfSize
		 * @param	color
		 * @return
		 */
		static	public function doDrawCircle(halfSize:int, color:uint = 0xffffff) :Shape
		{
			var circle:Shape = new Shape();
			circle.graphics.beginFill(color);
			circle.graphics.drawCircle(0, 0, halfSize);
			circle.graphics.endFill();
			return circle;
		}
		
		/**
		 *  矩形
		 * @param	width
		 * @param	height
		 * @param	color
		 * @param	lineColor
		 * @return
		 */
		static public function doDrawRectangle(width:uint, height:uint, color:uint = 0xffffff,lineColor:uint = 0 ) :Shape
		{
			var child:Shape = new Shape();
            child.graphics.beginFill(color);
			if (lineColor != 0)
				child.graphics.lineStyle(1, lineColor);
            child.graphics.drawRect( -width / 2, -height / 2, width, height);
            child.graphics.endFill(); 
			return child;
		}
		
		/**
		 *  圆角矩形
		 * @param	width
		 * @param	height
		 * @param	ellipseWidth
		 * @param	ellipseHeight
		 * @param	color
		 * @param	lineColor
		 * @return
		 */
		static public function drawRoundRect(width:uint, height:uint, ellipseWidth:int , ellipseHeight:int, color:uint = 0xffffff, lineColor:uint = 0 ) :Shape
		{
			var child:Shape = new Shape();
            child.graphics.beginFill(color);
			if (lineColor != 0)
				child.graphics.lineStyle(1, lineColor);
            child.graphics.drawRoundRect( -width / 2, -height / 2, width, height, ellipseHeight, ellipseWidth);
            child.graphics.endFill(); 
			return child;
		}
		
		
		/**
		 *  椭圆
		 * @param	width
		 * @param	height
		 * @param	color
		 * @return
		 */
		static public function doDrawEllipse(width:int, height:int, color:uint = 0xffffff):Shape
		{
			var child:Shape = new Shape();
            child.graphics.beginFill(color);
			
            child.graphics.drawEllipse(0, 0, width, height);
            child.graphics.endFill(); 
			return child;
		}
	}
	
}